package org.jeecg.modules.charge.mapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.entity.basedata.BaseFeeRule;
import org.jeecg.entity.basedata.RentContract;
import org.jeecg.entity.charge.CanGeBillsVo;
import org.jeecg.entity.charge.ChargeBills;
import org.jeecg.entity.charge.ChargeFeeitem;
import org.jeecg.modules.charge.entity.ChargeCollect;
import org.jeecg.modules.charge.model.ChargeGenerateModel;
import org.jeecg.modules.charge.vo.DictModel;
import org.jeecg.vo.charge.ChargeBillsJump;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description: 账单
 * @Author: jeecg-boot
 * @Date:   2019-08-08
 * @Version: V1.0
 */
public interface ChargeBillsMapper extends BaseMapper<ChargeBills> {
    public List<ChargeGenerateModel> getByGenerateCustomer(@Param("projectId")String projectId,@Param("floorId") String floorId,@Param("roomName") String roomName);

    public List<ChargeGenerateModel> getByGenerateTenant(@Param("projectId")String projectId,@Param("floorId") String floorId,@Param("roomName") String roomName);

//    public List<ChargeUtilityBillsByFee> getByBillStandardCusId(@Param("roomId") String roomId, @Param("feeIds") List<String> feeIds);

    public Integer getBillByCny(ChargeBills chargeBills);

    public Integer getBillByCnyCustomer(ChargeBills chargeBills);

    public List<ChargeBillsJump> getByChargeBills(@Param("ids") List<String> ids);

    public List<ChargeBills> getFeeItemId(@Param("ids") List<String> ids);

    public List<DictModel> getRoomproperty();

    @SqlParser(filter = true)
    public ChargeBills get(String id);

    public List<ChargeBills> listById(@Param("idBill") String[] idBill);

    public List<ChargeBills> listByBills(@Param("idsBo") List<String> idsBo);

    public ChargeFeeitem getByFeeCode(@Param("feeCode") String feeCode, @Param("projectId") String projectId);

    public  Integer updateBills(ChargeBills bills);

    public List<ChargeBills> getChargeBillsAll(Page<ChargeBills> page, @Param("chargeBills") ChargeBills chargeBills);//所有账单根据业主与租户的Id

    public List<ChargeBills> getByRoomBillss(@Param("chargeBills") ChargeBills chargeBills);//查询合并收费的账单业主或者租户


    public List<ChargeBills> getBillsByInvoiceNo(@Param("invoiceNo") String invoiceNo, @Param("invoiceGrnno") String invoiceGrnno);//根据票据簿编号与票据编号查询对应所有账单

    public Integer updateyOneUtily(ChargeBills chargeBills);

    public Integer updateDiscountMoney(@Param("money")BigDecimal money, @Param("ids") String[] ids);

    public Integer insertBills(ChargeBills chargeBills);

    public Integer updateInvoiceBills(ChargeBills chargeBills);

    public Integer deletChargeBillseById(ChargeBills chargeBills);

    public List<ChargeBills> findBillsPage(IPage<ChargeBills> page, @Param("chargeBills") ChargeBills chargeBills);

    public List<ChargeBills> selectHistoryById(@Param("billsId") String billsId);

    public Integer deleteHistory(@Param("pantId") String pantId);

    public List<ChargeBills> selectBillsAll(@Param("chargeBills") ChargeBills chargeBills);//不分页查询所有账单

    public Integer insertListHistory(@Param("chargeBills") List<ChargeBills> chargeBills);

    public List<ChargeCollect> getDayCollect(@Param("chargeCollect") ChargeCollect chargeCollect);//汇总表查询

    @Select("select fee_name from charge_feeitem  where fee_code = #{feeCode} and del_flag = '0'")
    String getByfeeName(@Param("feeCode") String feeCode);

    @Select("select name from base_project where id = #{projectId} AND del_flag = '0'")
    String selectProjectName(@Param("projectId") String projectId);

    @Select("SELECT phone FROM base_customer WHERE id = #{cusId} AND del_flag = '0'")
    String selectCusPhone(@Param("cusId") String cusId);

    @Select("SELECT mobile FROM base_tenant WHERE id = #{rentId} AND del_flag = '0'")
    String selectRenPhone(@Param("rentId") String rentId);

    List<ChargeBills> getChargeBills(@Param("chargeBills") ChargeBills chargeBills);// 根据条件查询未收账单

    public List<ChargeBillsJump> getBillsByJump(@Param("invoiceNo") String invoiceNo, @Param("invoiceGrnno") String invoiceGrnno);

    public List<ChargeBills> getPageBillsList(Page<ChargeBills> page, @Param("chargeBills") ChargeBills chargeBills);//所有账单根据房间的Id

    public List<ChargeBills> getBillsList(@Param("chargeBills") ChargeBills chargeBills);// 根据条件查询未收账单不分页

    public List<ChargeCollect> getCollarInvoice(@Param("chargeCollect") ChargeCollect chargeCollect);// 部门领用票据表

    public List<ChargeBills> getChargeBillsByInvoiceId(@Param("invoiceId") String invoiceId);

    //业主的最晚时间
    String getLastGenrateCustomerDate(@Param("roomId") String roomId,@Param("feeId") String feeId);

    //租户的最晚时间
    String getLastGenrateTenantDate(@Param("roomId") String roomId,@Param("feeId") String feeId);

    //房间收费项最晚的应收日期
    String getLastBillDate(@Param("roomId") String roomId,@Param("feeId") String feeId);

    @SqlParser(filter = true)
    Integer updateBillsBatch(@Param("list") List<ChargeBills> billsList);

    List<ChargeBills> findByOrderId(@Param("orderId")  String orderId);

    void deleteByOrderId(@Param("orderId") String orderId);

    List<ChargeBills> findByTableId(@Param("tableId") String tableId,@Param("id") String id);

    Integer getMaxBillsNum(@Param("chargeBills") ChargeBills chargeBills);

    //获取账单最后日期
    String getLastZjCny(@Param("chargeBills") ChargeBills chargeBills);

    @SqlParser(filter = true)
    List<ChargeBills> getBillsByIds(@Param("ids") List<String> ids);

    List<ChargeBills> queryRoomBills(@Param("roomIdList") List roomId,@Param("spiltDate")String spiltDate);

    List<ChargeBills> findPage(Page<ChargeBills> page,@Param("bean") ChargeBills chargeBills);

    void billDelete(@Param("id") String id);

    void batchBillDelete(@Param("id") List<String> ids);

    List<ChargeBills> queryContractBills(@Param("contractId") String contractId);

    BaseFeeRule getBaseFeeRuleById(@Param("feeRuleId")String feeRuleId);

    List<RentContract> getByContractIds(@Param("contractIds") String [] contractIds);

    List<ChargeBills> queryRoomAllBills(@Param("roomIdList") List<String> roomIdList);

    List<ChargeBills> queryContractAllBills(@Param("contractId") String contractId,@Param("zjCny") String zjCny);

    void canCellAndGenerateRoomBills(@Param("cancellBillsVoList") List<CanGeBillsVo> cancellBillsVoList);

    ChargeBills getMaxPayBills(@Param("roomId") String roomId);

    void canCellBills(@Param("roomIds") List<String> roomId, @Param("spiltDate") String spiltDate);

    void canCellAllBills(@Param("roomIds") List<String> roomId);
}
